﻿Global.namespace("System.Core.Handler");
System.Core.Handler.StringHandler={};
System.Core.Handler.StringHandler.format=function(format){
    try{
        var args = Array.prototype.slice.call(arguments, 1);
        return format.replace(/\{(\d+)\}/g, function(m, i){
            return args[i];
        });
    }catch(e){
        throw e;
    }
}
System.Core.Handler.StringHandler.replace=function(input,bookmark, value){
    for(;input.indexOf(bookmark)>=0;){
        input = input.replace(bookmark, value);
    }
    return input;
}
System.Core.Handler.StringHandler.removeMidText=function(input, maxLength){
    // return original string if length of input string is shorter than maxLegnth
    if(input.length< maxLength){ return input;}
    // remove relevant letter at the middle of string
    maxLength-=5;
    var removeFrom=parseInt(maxLength/2);
    var removeTo=input.length-removeFrom;
    var outputString=input.substr(0, removeFrom)+"....."+input.substr(removeTo, input.length);

    return outputString;
}
// shorten reference to object
var StringHandler = System.Core.Handler.StringHandler;
